package cc.rengu.igas.share.facade.bean.cups;

import cc.rengu.oltp.service.common.enums.OltpRpcdEnum;
import cc.rengu.oltp.service.model.BizException;

import java.util.Arrays;

/**
 * F104 附加信息
 *
 * @author yangfan
 * @version 1.0
 * @date 2021/5/6
 */
@SuppressWarnings("AlibabaEnumConstantsMustHaveComment")
public enum F104_PI_04_DeviceType {
    _01("01", "自动柜员机（含ATM和CDM）和多媒体自助终端"),
    _02("02", "传统POS"),
    _03("03", "mPOS"),
    _04("04", "智能POS"),
    _05("05", "II型固定电话"),
    ;

    private String code;
    private String desc;

    F104_PI_04_DeviceType(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    @Override
    public String toString() {
        return code + "-" + desc;
    }

    public static F104_PI_04_DeviceType find(String code) {
        F104_PI_04_DeviceType result = Arrays.stream(F104_PI_04_DeviceType.values())
                .filter(e -> e.getCode().equals(code)).findFirst().orElse(null);

        if (result == null) {
            throw new BizException(OltpRpcdEnum.PARAM_IS_EMPTY_OR_NULL.getRespCode(), "找不到对应的枚举信息" + code);
        }
        return result;
    }
}
